<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="${_ctx}">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="css/htcomlistcs.css" />
<style>
	.chongfuselect{
		position: fixed;
		top: 211px;
		left: 480px;
		background-color: rgba(0,0,0,0.5);
		color: #fff;
		width: 160px;
		height: 60px;
		line-height: 60px;
		text-align: center;
		border-radius: 5px;
		font-size: 14px;
		z-index: 9999;
		display: none;
	}
</style>
		<script type="text/javascript" src="js/jquery-2.2.3.min.js"></script>
		<script type="text/javascript">
			var i=0;
			$(function(){
				$(".selecttiaojian").click(function(){
					$(".dropdown-menu").toggle();
				})
				
				//全选按钮
				$("#selectall").click(function(){
					if(i%2==0){
						$(".list-table").find("input[type=checkbox]").prop('checked', true);
					}else{
						$(".list-table").find("input[type=checkbox]").prop('checked',false);
					}
					i++;
					
				})
				
				
				//取消订单事件
				$("#quxiao").click(function(){
					var open=true;
					var shu=0;
					$(".list-table").find("input[type=checkbox]").each(function(i,v){
						if(v.checked){
							$(v).parents("tr").find(".orstatus").each(function(i,v){
								if($(v).find("a").text()!="待支付"){
									open=false;
								}
							});
							shu++;
						}
					})
					if(shu==0){
						$(".chongfuselect").text("未选中订单")
						$(".chongfuselect").fadeIn(700);
						$(".chongfuselect").fadeOut(700);
						return;
					}
					if(open){
						$(".list-table").find("input[type=checkbox]").each(function(i,v){
							if(v.checked){
								var $orid=$(v).attr("orid");
								$(v).parents("tr").find(".orstatus a").text("已取消");
								$.ajax({
									type:"post",
									url:"htmain?v=uporder",
									data:"orid="+$orid+"&orstatus=已取消",
									success:function(msg){
										
									}
								})
								$(".chongfuselect").text("取消成功")
								$(".chongfuselect").fadeIn(700);
								$(".chongfuselect").fadeOut(700);
							}
						})
					}else{
						$(".chongfuselect").text("存在不能取消的订单")
						$(".chongfuselect").fadeIn(700);
						$(".chongfuselect").fadeOut(700);
						return;
					}
				})
			})
		</script>
	</head>
	<body>
		<div class="chongfuselect">
			<p>未选中商品</p>
		</div>
		<div class="lg-side">
			<div class="inbox-head">
				<h3>订单列表</h3>
				<form class="pull-right position" action="htmain?v=selectorid" method="post">
					<input type="text" placeholder="请输入订单号" class="sr-input" name="orid" />
					<button type="submit" class="btn sr-btn">
						<div>
							<img src="imgs/htimgs/sousuo.png" />
						</div>
					</button>
				</form>
			</div>
			<div class="inbox-body">
				<div class="mail-option">
					<div class="btn-group">
						<a class="btn-a selecttiaojian">
							请选择查询条件
							<img src="imgs/htimgs/selectxiala.png" />
						</a>
						<ul class="dropdown-menu">
							<li>
								<a href="htmain?v=selectorstatus&orstatus=待支付">
									<img src="imgs/htimgs/spshangjia.png" />
									待支付
								</a>
							</li>
							<li>
								<a href="htmain?v=selectorstatus&orstatus=已支付">
									<img src="imgs/htimgs/spxiajia.png" />
									已支付
								</a>
							</li>
							<li>
								<a href="htmain?v=selectorstatus&orstatus=已发货">
									<img src="imgs/htimgs/spxiajia.png" />
									已发货
								</a>
							</li>
							<li>
								<a href="htmain?v=selectorstatus&orstatus=已完成">
									<img src="imgs/htimgs/spxiajia.png" />
									已完成
								</a>
							</li>
							<li>
								<a href="htmain?v=selectorstatus&orstatus=已取消">
									<img src="imgs/htimgs/spxiajia.png" />
									已取消
								</a>
							</li>
						</ul>
					</div>
					<div class="btn-group">
						<a class="btn-a" href="htmain?v=htorder">
							查询所有
						</a>
					</div>
					<div class="btn-group">
						<a class="btn-a" id="selectall">
							全选
						</a>
					</div>
					<div class="btn-group">
						<a class="btn-a" id="quxiao">
							取消订单
						</a>
					</div>
					<ul class="unstyled pull-right">
						<li>
							<span>${orpager.pageNo}</span>
							<span>/</span>
							<span>${orpager.getPageCount()}</span>
						</li>
						<li>
							<a href="htmain?v=${ormethod}&pageno=${orpager.getPrev()}&orstatus=${orstatus}&orid=${orid}">
								<img src="imgs/htimgs/fyleft.png" >
							</a>
						</li>
						<li>
							<a href="htmain?v=${ormethod}&pageno=${orpager.getNext()}&orstatus=${orstatus}&orid=${orid}">
								<img src="imgs/htimgs/fyright.png" >
							</a>
						</li>
					</ul>
				</div>
				
				<table class="list-table">
					<thead>
						<tr>
							<th></th>
							<th>订单号</th>
							<th>收货人</th>
							<th>订单状态</th>
							<th>支付方式</th>
							<th>金额</th>
							<th>用户名</th>
							<th>下单时间</th>
							<th>操作</th>
						</tr>
					</thead>
					<c:forEach var="c" items="${orpager.data}">
					<tr>
						<td>
							<input orid="${c.orid}" type="checkbox" />
						</td>
						<td>
							${c.orid}
						</td>
						<td>
							<a>${c.oruser}</a>
						</td>
						<td class="orstatus">
							<a>${c.orstatus}</a>
						</td>
						<td>
							<a>${c.orpayment}</a>
						</td>
						<td>
							<a>￥<span>${c.orprice}</span></a>
						</td>
						<td>
							<a>${c.uname}</a>
						</td>
						<th>
							<a>${c.ortime}</a>
						</th>
						<td>
							<a href="htmain?v=htorderxq&orid=${c.orid}">
								<img src="imgs/htimgs/spbianji.png" />
							</a>
						</td>
					</tr>
					</c:forEach>
				</table>
			</div>
		</div>
	</body>
</html>